import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
    vueSetupExtend()
  ],
  server: {
    host: 'localhost',
    port: 7777,
    open: true,
    proxy: {
      '/conner': {
        target: 'https://api.it120.cc',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/conner/, '/conner')
      }
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@c': fileURLToPath(new URL('./src/components', import.meta.url)),
      '@s': fileURLToPath(new URL('./src/stores', import.meta.url)),
      '@u': fileURLToPath(new URL('./src/utils', import.meta.url)),
      '@a': fileURLToPath(new URL('./src/api', import.meta.url)),
      '@v': fileURLToPath(new URL('./src/views', import.meta.url))
    }
  }
})
